<?php

	/*
		Class Name: dbConnector
		Description: Provides a centrilized object to handle connections to database
		Created On: March 16, 2014
		Created By: Lenin Rodríguez
		History:
		
	*/
	class dbConnector {
			var $dbusername;
			var $dbuserpassword;
			var $hostname;
			var $db;
			var $connectorMessage;
			var $dbLink;
			var $dbResult;
			
			function dbConnector(){				
				$this->dbusername = 'root';
				$this->dbuserpassword = 'password';
				$this->hostname = 'localhost';				
				$this->db = 'rtms';								
				}
			function openConnection(){
					$this->connectorMessage = '';
					$this->dbLink = mysqli_connect ($this->hostname, $this->dbusername, $this->dbuserpassword, $this->db);					
					if (mysqli_connect_errno()){
						$this->connectorMessage = mysqli_connect_error();
						return false;
					}else{
						return true;
					}
				}						
			function message() {$this->connectorMessage;}
			function closeConnection(){$this->dbLink->close();}			
			function query($query) {$this->dbResult = mysqli_query($this->dbLink,$query);}
			function queryLink() {return $this->dbLink;}
			function queryResults(){ return $this->dbResult;}
	}
?>